#include "server_backend.h"
#include "server_session_layer.h"

/* generates the calculation answer */
int 
getResponse(void* responseData, void* receivedData)
{
	req_packageT* receivedStruct;
	ans_packageT* returnStruct;
	double response;

	receivedStruct = (req_packageT*)receivedData;

	switch(receivedStruct->opcode)
	{
		case ADD_OP:
			response = add(receivedStruct->op1, receivedStruct->op2);
			break;
		case SUB_OP:
			response = sub(receivedStruct->op1, receivedStruct->op2);
			break;
		case MULT_OP:
			response = mult(receivedStruct->op1, receivedStruct->op2);
			break;
		case DIV_OP:
			response = divide(receivedStruct->op1, receivedStruct->op2);
			break;
	}
	returnStruct = (ans_packageT*)responseData ;
	returnStruct->ans = response;

	return sizeof(ans_packageT);
}

